{% extends '::base.html.twig' %}

{% block topbar %}
<div id="topbar" style="background: url('/images/green.png') repeat-x scroll 0 0 #B0B0B0">
    <strong class="wrapper">
        {{ type }} Projects
    </strong>
</div>
{% endblock %}

{% block bodyclass %} class="fullwidth"{% endblock %}

{% block body %}
<div class="wrapper">
    <div id="content">
        <div class="entry">
        {% for entity in entities %}
        <div class="one-third portfolio-item{% if ((loop.index-1) % 3) == 2 %} last{% endif %}">
            {% if entity.getWebPath() %}
                <img class="rounded" src="{{ entity.getWebPath() }}" alt='{{ entity.name }}' width='280' height='125' />
            {% endif %}
            <h3><a href="{{ url('project_show', { 'id': entity.id }) }}">{{ entity.name | capitalize }}</a></h3>
            <p>
                {{ entity.description }}
                <span class="read-more">
                    {% if entity.website %}
                    <a href="{{ entity.website }}" title="{{ entity.name }}" target="_blank" rel="nofollow">Visit Site</a>
                    {% endif %}
                    <a href="{{ url('project_show', { 'id': entity.id }) }}">Read more »</a>
                </span>
            </p>
        </div>
        {% if ((loop.index-1) % 3) == 2 %}<div class="big-spacer"></div>{% endif %}
        {% endfor %}

        <div class="big-spacer"></div>

        {% if lastPageNumber > 1 %}
        <div class="paginator">
            <div class="pagingContainer">
                {% if page > 1 %}
                    <a href="{{ url('project_type', {'type': type}) }}" class="first">First</a>
                    <a href="{{ url('project_type', {'type': type, 'page' : page - 1}) }}">« Prev</a>
                {% endif %}
                <div>
                    {% for numberOfPage in 1..lastPageNumber %}
                        <a href="{{ url('project_type', {'type': type, 'page' : numberOfPage}) }}" class="
                        {% if (numberOfPage == lastPageNumber) and (numberOfPage == page) %}
                        last
                        {% elseif (numberOfPage == 1) and (numberOfPage == page) %}first{% endif %}
                        {% if numberOfPage == page %}
                         active{% endif%}">{{ numberOfPage }}</a>
                        
                    {% endfor %}
                </div>
                {% if page < lastPageNumber %}
                    <a href="{{ url('project_type', {'type': type, 'page' : page + 1}) }}">Next »</a>
                    <a href="{{ url('project_type', {'type': type, 'page' : lastPageNumber}) }}" class="last">Last</a>
                {% endif %}
            </div>
        </div>
        {% endif %}
        </div>
        <!-- END .entry -->

    </div>
    <!-- END #content -->      

</div>
<!-- END .wrapper -->
{% endblock %}